<!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>办公系统 - 基础表格</title>
    <meta name="keywords" content="办公系统">
    <meta name="description" content="办公系统">

    <link rel="shortcut icon" href="favicon.ico"> 
    	<link href="css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="css/animate.min.css" rel="stylesheet">
    <link href="css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link href="css/plugins/select/bootstrap-select.min.css" rel="stylesheet">
	<link href="css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        
      <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>员工管理<small>>修改信息</small></h5>
                    </div>
                    <div class="ibox-content">
                        <form method="get" id="updateForm"  class="form-horizontal">
                            <input type="hidden" name="deptno" />
                       	<div class="row">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">部门名称</label>
                                <div class="col-sm-3">
                                    <input name="dname" type="text" class="form-control input-sm">
                                </div>
                                <label class="col-sm-2 col-sm-offset-1 control-label">部门位置</label>
                                <div class="col-sm-3">
                                    <input name="local" type="text" class="form-control input-sm">
                                </div>
                            </div>
                        </div>
                        
                        
                     	<div class="row">
                     		<div class="hr-line-dashed"></div>
                     	</div>
                          
                         <div class="row">
                            <div class="form-group">
                                <div class="col-sm-3 col-sm-offset-3 text-right">
                                    <button type="button" id="btn" class="btn btn-primary"><i class="fa fa-save"></i> 保存内容</button>
                                </div>
                                <div class="col-sm-3">
                                	<a href="list-dept.html" class="btn btn-white"><i class="fa fa-reply"></i> 返回</a>
                                	</div>
                            </div>
                       </div>
                       </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

 
    
    
    <script src="js/jquery.min.js?v=2.1.4"></script>
    <script src="js/bootstrap.min.js?v=3.3.6"></script>
    <script src="js/plugins/sweetalert/sweetalert.min.js"></script>
	<script src="js/plugins/select/bootstrap-select.min.js"></script>
	<script src="js/plugins/layer/laydate/laydate.js"></script>
    <script src="js/jquery.serializejson.min.js" type="text/javascript" charset="utf-8"></script>
   <script>
	$(document).ready(function() {
		// 设置按钮的样式
		$('.selectpicker').selectpicker('setStyle', 'btn-white');
		//初始化日期控件
		// laydate({elem: "#start"});
	
		
	});
   </script>
   <!-- 修复日期控件长度-->
   <link href="css/customer.css" rel="stylesheet">

    <script>
        $(function () {
            var str = window.location.search

            console.log(str)
            var id = str.substring(str.lastIndexOf("id")+"id".length+1)

            console.log(id)
            $("input[name='deptno']").val(id)

            $.ajax({
                url:"dept/"+id,
                type:"get",
                dataType:"json",
                success:function(ret){
                    if(ret.status){
                        $("input[name='dname']").val(ret.data.item.dname)
                        $("input[name='local']").val(ret.data.item.local)
                    }
                }
            })


            $("#btn").click(function(){

                var data = $("#updateForm").serializeJSON()

                $.ajax({
                    url:"dept/update",
                    type:"post",
                    data:JSON.stringify(data),
                    dataType:"json",
                    contentType:"application/json",
                    success:function(ret){
                        if(ret.status){
                            window.location.href="list-dept.html"
                        }
                    }

                })

            })
        })
    </script>
</body>


</html>